# -*- coding: utf-8 -*-
from Page.noscanningPage import noscanningPage
from Page.manreviewPage import manreviewPage
import time
from selenium.webdriver.support.ui import Select
from selenium.webdriver import ActionChains
class manreview():
    def __init__(self,driver):
        self.driver=driver
        self.noscanningPage=noscanningPage(self.driver)
        self.manreviewPage=manreviewPage(self.driver)
    def manreviewpage(self):
        self.manreviewPage.btnManReview().click()
        time.sleep(1)
    def query_manreview(self,GrpPropNo):
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        # 输入投保单号
        self.manreviewPage.inpGrpPropNo().send_keys(GrpPropNo)
        time.sleep(1)
        # 点击查询
        self.manreviewPage.btnrefer1().click()
        time.sleep(1)
    def self_goto_public(self):
        # 公共池选择
        self.manreviewPage.btnQueryScanGridSel().click()
        time.sleep(3)
        # 申请
        self.manreviewPage.btnapply1().click()
        time.sleep(1)
        window1 = self.driver.window_handles
        self.driver.switch_to.window(window1[-1])
        self.noscanningPage.butSubmit().click()
        # 个人池
        windows2 = self.driver.window_handles
        self.driver.switch_to.window(windows2[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        # 个人池选择
        self.manreviewPage.btnScanMyInfoGridSel().click()
        time.sleep(1)
        # 进入人工核保
        self.manreviewPage.btnGoInside1().click()
        time.sleep(1)
        # 核保处理
        self.manreviewPage.btnUnderWriting().click()
        time.sleep(1)
        windows3 = self.driver.window_handles
        self.driver.switch_to.window(windows3[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)

    def UnderWritingProcess(self,UWConclusion,UWOption):
        radio=self.manreviewPage.radAutoUWIfm()
        number=len(radio)
        print('u"获取总个数：%s" %number')
        for j in range(number):
            radio[j].click()
            ActionChains(self.driver).double_click(self.manreviewPage.btnUWConclusion()).perform()
            time.sleep(1)
            Select(self.manreviewPage.secUWConclusion()).select_by_visible_text(UWConclusion)
            time.sleep(1)
            self.manreviewPage.inpUWOption().send_keys(UWOption)
            time.sleep(1)
            self.manreviewPage.btnSaveConclusion().click()
            time.sleep(1)
            windows4 = self.driver.window_handles
            self.driver.switch_to.window(windows4[-1])
            self.noscanningPage.butSubmit().click()
            time.sleep(1)
            windows5 = self.driver.window_handles
            self.driver.switch_to.window(windows5[-1])
            self.driver.switch_to.default_content()
            self.driver.switch_to.frame("fraInterface")
            time.sleep(1)
            radio = self.manreviewPage.radAutoUWIfm()
            time.sleep(1)
            # self.driver.refresh()
            # time.sleep(1)
    def InsuredListConfirm(self):
        # 点击被保险人列表显示
        self.manreviewPage.tabInsuredList().click()
        time.sleep(1)
        windows1 = self.driver.window_handles
        self.driver.switch_to.window(windows1[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        # 点击整单核保
        self.manreviewPage.btnWholeListUw().click()
        time.sleep(1)
        # 确认
        self.driver.switch_to_alert().accept()
        time.sleep(1)
        windows2 = self.driver.window_handles
        self.driver.switch_to.window(windows2[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)
        windows3 = self.driver.window_handles
        self.driver.switch_to.window(windows3[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        # ActionChains(self.driver).double_click(self.manreviewPage.btnUWConclu()).perform()
        # time.sleep(1)
        # Select(self.manreviewPage.secUWConclu()).select_by_visible_text(UWConclu)
        # time.sleep(1)
        # self.manreviewPage.inpUWIdea().send_keys(UWIdea)
        # time.sleep(1)
        self.manreviewPage.btnUwPageClose().click()
        time.sleep(1)
        windows4 = self.driver.window_handles
        self.driver.switch_to.window(windows4[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        self.manreviewPage.btnWholeUWComfire().click()
        time.sleep(1)
        windows4 = self.driver.window_handles
        self.driver.switch_to.window(windows4[-1])
        self.noscanningPage.butSubmit().click()
        time.sleep(1)







